﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Web.Library.DomainObject.SQLServer;
using Web.Library.DataAccess.SQLServer;
using Web.Library.Enum;

namespace Web.Library.Facade.SQLServer
{
    //public sealed class ProductsFacadeExt : Facade.SQLServer.ProductsFacade
    //{
    //    private string connectionString;
    //    private ProductsFacade dal = null;

    //    public ProductsFacadeExt(string connection) : base(connection)
    //    {
    //        connectionString = connection;
    //        dal = new ProductsFacade(connectionString);

    //    }

    //    public override DomainObject.SQLServer.Products GetById(int key)
    //    {
    //        Products newObj = base.GetById(key);

    //        ProductsRepo dal = new ProductsRepo(connectionString);
    //        newObj.Categories = new Lazy<Categories>(() => dal.LoadCategory(newObj.CategoryID, null));
    //        newObj.Suppliers = new Lazy<Suppliers>(() => dal.LoadSupplier(newObj.SupplierID, null));

    //        return newObj;
    //    }

    //    public override List<DomainObject.SQLServer.Products> GetList()
    //    {
    //        List<Products> products = base.GetList();

    //        ProductsRepo dal = new ProductsRepo(connectionString);
            
    //        products.ForEach(delegate(Products product)
    //        {
    //            product.Categories = new Lazy<Categories>(() => dal.LoadCategory(product.CategoryID, connectionString));
    //            product.Suppliers = new Lazy<Suppliers>(() => dal.LoadSupplier(product.SupplierID, connectionString));                
    //        });

    //        return products;
    //    }

    //    public override List<DomainObject.SQLServer.Products> GetList(int pageSize, int currentPage, string sortName, string sortOrder)
    //    {
    //        List<Products> products = base.GetList(pageSize, currentPage, sortName, sortOrder);

    //        ProductsRepo dal = new ProductsRepo(connectionString);

    //        products.ForEach(delegate(Products product)
    //        {
    //            product.Categories = new Lazy<Categories>(() => dal.LoadCategory(product.CategoryID, connectionString));
    //            product.Suppliers = new Lazy<Suppliers>(() => dal.LoadSupplier(product.SupplierID, connectionString));
    //        });

    //        return products;

    //    }

    //}

    //public partial class ProductsFacade
    //{        
    //    public List<DomainObject.SQLServer.Products> GetList(int pageSize, int currentPage, string sortName, string sortOrder, string parameter)
    //    {
    //        List<Products> products = dal.GetList(pageSize, currentPage, sortName, sortOrder, parameter);

    //        products.ForEach(delegate(Products product)
    //        {
    //            product.Categories = new Lazy<Categories>(() => dal.LoadCategory(product.CategoryID, null));
    //            product.Suppliers = new Lazy<Suppliers>(() => dal.LoadSupplier(product.SupplierID, null));
    //        });

    //        return products;

    //    }

    //    public object SelectScalar(SQL.Function.Aggregate function, string column, string parameter)
    //    {
    //        return dal.SelectScalar(function, column, parameter);
    //    }
    //}

}
